package com.vito.dcs.statistics.action;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.dubbo.config.annotation.Reference;
import com.vito.base.authoriza.action.BaseAction;
import com.vito.base.model.ResMsg;
import com.vito.base.model.Result;
import com.vito.base.tools.I18nResMsg;
import com.vito.dcs.statistics.service.SectionStatisticsService;

@Controller
@RequestMapping("/dcs/statistics")
public class SectionStatisticsAction extends BaseAction{
	
	private static final Logger log = LoggerFactory.getLogger(SectionStatisticsAction.class);
	@Reference
	private SectionStatisticsService sectionStatisticsService;
	
	@RequestMapping("/querySectionStatistics")
	@ResponseBody
	public Result querySectionStatistics(@RequestParam Map<String,Object> map){
		Result res = new Result();
		try {
			Map<String, Object> querySectionStatistics = sectionStatisticsService.querySectionStatistics_new(map);
			res.setCode(Result.CODE_OK);
			res.setData(querySectionStatistics);
		} catch (Exception e) {
			res.setCode(Result.CODE_ERROR);
			res.setMsg(I18nResMsg.EXECERR());
			log.error(ResMsg.EXECERR, e);
		}
		return res;
	}
	@RequestMapping("/querySectionStatistics2")
	@ResponseBody
	public Result querySectionStatistics2(@RequestParam Map<String,Object> map){
		Result res = new Result();
		try {
			List<Map<String, Object>> querySectionStatistics2 = sectionStatisticsService.querySectionStatistics2(map);
			res.setCode(Result.CODE_OK);
			res.setData(querySectionStatistics2);
		} catch (Exception e) {
			res.setCode(Result.CODE_ERROR);
			res.setMsg(I18nResMsg.EXECERR());
			log.error(ResMsg.EXECERR, e);
		}
		return res;
	}
	@RequestMapping("/queryLayer")
	@ResponseBody
	public Result queryLayer(@RequestParam Map<String,Object> map){
		Result res = new Result();
		try {
			List<Map<String, Object>> queryLayer = sectionStatisticsService.queryLayer(map);
			res.setCode(Result.CODE_OK);
			res.setData(queryLayer);
		} catch (Exception e) {
			res.setCode(Result.CODE_ERROR);
			res.setMsg(I18nResMsg.EXECERR());
			log.error(ResMsg.EXECERR, e);
		}
		return res;
	}
	
}
